function backTop(){}

$.extend(backTop.prototype , {
    init : function(){
        //back可以成功运行
        console.log(" i am back");
        //获取元素
        this.back_top = $(".back-top");
        this.the_top  = $("#the-top");
        this.nav_top  = $("#nav-top");

        //点击进入购物车
       
        this.topbar_cart = $(".topbar-cart");
        this.backCart    = $(".back-cart");

        //绑定事件
        this.back_top.on("mouseenter","li",$.proxy(this.showSpan,this));
        this.back_top.on("mouseleave","li",$.proxy(this.noneSpan,this));
        //点击返回顶部
        this.the_top.on("click",$.proxy(this.returnTop,this));
        $(window).on("scroll",$.proxy(this.showPlane,this));
              
        this.topbar_cart.on("click",$.proxy(this.goBackCart,this));
        this.backCart.on("click",$.proxy(this.goBackCart,this));

    },
    showSpan : function(evt){
        var e = evt || window.event;
        var target = e.target || e.srcElement;
        // console.log(target.nodeName)
        
        $($(target).closest("li").find(".glyphicon")).css("display","none");
        $($(target).closest("li").find(".backShow")).css("display","inline");
    },
    noneSpan : function(evt){
        var e = evt || window.event;
        var target = e.target || e.srcElement;
       
        $($(target).closest("li").find(".glyphicon")).css("display","inline-block");
        $($(target).closest("li").find(".backShow")).css("display","none");
    },
    showPlane : function(){
        // console.log(this.nav_top);
        var scrollTop = $("html,body").scrollTop();
        scrollTop >= 600 ? this.the_top.css("display" ,"list-item") : this.the_top.css("display" ,"none");
        scrollTop > 40 ? this.nav_top.addClass("site-header-fixed") : this.nav_top.removeClass("site-header-fixed");
    },
    returnTop : function(){
        clearInterval(timer);
        var timer = setInterval($.proxy(function(){
            var scrollTop = $("body,html").scrollTop();
            scrollTop -=Math.ceil(scrollTop/10);
            window.scrollTo(0,scrollTop);
            scrollTop === 0 && clearInterval(timer);
        },this),15)
    },
    goBackCart : function(){
        location.href = "http://localhost/js/test/konka/html/carts.html";
    }
})

export default new backTop();